"""
Models for the Map application.
"""

from django.db import models

# The models of the "Map" application

class Service(models.Model):
  """Stores information about the map services we are able to connect to"""
  name = models.CharField(max_length=200, unique=True)
  url  = models.CharField(
          max_length=200,
          help_text='The template for building the final url, you may need to include formatting tags : %(xSize)s, %(ySize)s, %(x)s, %(y)s, %(z)s, %(key)s')
  key  = models.CharField(
          max_length=200, blank=True,
          help_text='A unique authentication key for the mapping service')
  
  def __unicode__(self):
    return self.name
  
  class Meta:
    unique_together = ('url', 'key')
    ordering        = ('name',)
    verbose_name    = 'Mapping service'
  
  class Admin:
    search_fields   = ('name', 'url', 'key')
  
